<template>
	<u-avatar mode="aspectFill" :text="text" fontSize="18" :src="avatar" :size="size" randomBgColor>
	</u-avatar>
</template>

<script>
	import store from '@/store'
	import config from '@/config'
	const baseUrl = config.baseUrl
	export default {
		props: {
			size: {
				type: String,
				default: '126rpx',
			}
		},
		computed: {
			userInfo() {
				const {
					user
				} = store.state;
				return user;
			},
			avatar() {
				return baseUrl + this.userInfo.avatar;
			}
		},
		data() {
			return {
				text: ''
			}
		},
		created() {
			if (this.avatar) {
				return;
			}
			this.text = this.userInfo.name.slice(0, 3);
		}
	}
</script>